package org.darcy.service.impl;

import java.util.List;

import org.darcy.dao.BizTypeMapper;
import org.darcy.entity.BizType;
import org.darcy.framework.generic.GenericServiceImpl;
import org.darcy.model.BizTypeModel;
import org.darcy.service.BizTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * 分类
 */
@Service
public class BizTypeServiceImpl extends GenericServiceImpl<BizType> implements BizTypeService {

	@Autowired
	private BizTypeMapper bizTypeMapper;
	
	@Override
	public List<BizTypeModel> listParent() {
		List<BizTypeModel> list = bizTypeMapper.listParent();
		return list;
	}

	@Override
	public List<BizTypeModel> listTypeForMenu() {
		List<BizTypeModel> entityList = bizTypeMapper.listTypeForMenu();
		return entityList;
	}

	@Override
	public List<BizType> listTypeByPosition(String position) {
		QueryWrapper<BizType> q = new QueryWrapper<BizType>();
		q.eq("position", StringUtils.isEmpty(position) ? "scrollmenu" : position).eq("available", true);
		q.orderByAsc("sort");
		List<BizType> entityList = bizTypeMapper.selectList(q);
		return entityList;
	}



}
